import java.util.Scanner;

public class Main {


    //二维前缀和
    //先输入 n,m,q
    // n 代表行数，m代表列数，q 代表处理次数
    //初始化二维数组a和sum
    // 输入二维数组a，并计算前缀和sum
    //先处理一维前缀，再处理二维前缀
    //处理q次查询
    //将四个参数和 二维数组sum 传入 getSum 函数进行计算处理，输出结果
    //getSum: return sum[x2][y2] - sum[x1 - 1][y2] - sum[x2][y1 - 1] + sum[x1 - 1][y1 - 1];

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        int q = scan.nextInt();

        int[][] a = new int[n + 1][m + 1];
        int[][] sum = new int[n + 1][m + 1];
        for (int i = 1; i <= n ; i++) {
            for (int j = 1; j <= m ; j++) {
                a[i][j] = scan.nextInt();
                sum[i][j] = sum[i][j - 1] + a[i][j];
            }
            //二维前缀和
            for (int j = 1; j <= m ; j++) {
                sum[i][j] += sum[i - 1][j];
            }
        }

        for (int i = 0; i < q; i++) {
            int x1 = scan.nextInt();
            int y1 = scan.nextInt();
            int x2 = scan.nextInt();
            int y2 = scan.nextInt();
            System.out.println(getSum(x1,y1,x2,y2,sum));
        }
    }

    private static int getSum(int x1, int y1, int x2, int y2, int[][] sum) {
        if(x1 > x2 || y1 > y2) return 0;
        return sum[x2][y2] - sum[x2][y1 - 1] - sum[x1 - 1][y2] + sum[x1 - 1][y1 - 1];
    }
}
